package com.example.jdt_xiazai.fragment;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.jdt_xiazai.R;
import com.example.jdt_xiazai.adapter.HomeRlvAdapter;
import com.example.jdt_xiazai.base.BaseFragment;
import com.example.jdt_xiazai.bean.FuLiBean;
import com.example.jdt_xiazai.presenter.MainPresenter;
import com.example.jdt_xiazai.view.MainView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

public class HomeFragment extends BaseFragment<MainPresenter> implements MainView {

    @BindView(R.id.rlv)
    RecyclerView rlv;
    private HomeRlvAdapter adapter;

    @Override
    protected void initData() {
        basePresenter.getData();
    }

    @Override
    protected void initView() {
        rlv.setLayoutManager(new LinearLayoutManager(getContext()));
        ArrayList<FuLiBean.DataBean.DatasBean> datasBeans = new ArrayList<>();
        adapter = new HomeRlvAdapter(getActivity(), datasBeans);
        rlv.setAdapter(adapter);
    }

    @Override
    protected MainPresenter initPresenter() {
        return new MainPresenter();
    }

    @Override
    protected int getLayout() {
        return R.layout.home;
    }

    @Override
    public void showData(List<FuLiBean.DataBean.DatasBean> dataBeans) {
        adapter.initData(dataBeans);
    }
}
